// Fps Counter
// (c) jimon game studio

#ifndef JEH_IFPSCOUNTER
#define JEH_IFPSCOUNTER

#include "Config_Engine.h"
#include "jeSingleton.h"
#include "jeUnknown.h"

namespace je
{
	namespace core
	{
		//! Fps Counter
		class IFpsCounter:public je::jeUnknown
		{
		public:
			
			//! Destructor
			virtual ~IFpsCounter()
			{
			}

			//! Return Current Fps
			virtual f32 GetFps() = 0;

			//! Return true if fps updated
			virtual u1 IsUpdated() = 0;

			//! Fps Counter update mode
			enum FpsCounterUpdateMode
			{
				//! Update with delta time (fps counter use this mode by default)
				FCUM_USER,

				//! Update with tick time
				FCUM_TICK,

				//! Return arithmetic mean of all tick times in delta time perion
				FCUM_DOUBLE,
			};

			//! Set Update Mode
			virtual void SetUpdateMode(FpsCounterUpdateMode Mode,f32 NewDeltaTime = 1000.0f) = 0;

			//! Get Delta Time
			virtual f64 GetDT() = 0;

			//! Delta Time Correction Mode
			enum DeltaTimeCorrectionMode
			{
				//! Return Delta Time only by last frame
				DTCM_NONE,

				//! Return Delta Time by arithmetic mean of N frames delta times (N is morph level)
				DTCM_NICE,
			};

			//! Set Delta Time Correction Mode
			virtual void SetDTCorrectionMode(DeltaTimeCorrectionMode Mode,u32 NewMorphLevel = 32) = 0;

			//! Set Delta Time Default FPS
			virtual void SetDTDefaultFps(f32 Fps = 60.0) = 0;

			//! If false - disable dt, getdt will return 1.0
			virtual void SetDTEnable(u1 Enable) = 0;

			//! Loop Tick, needed only for low-level work, if you use IApplication - dont call this
			virtual void LoopTick() = 0;
		};

		DECLARE_SINGLETON_E(JE_ENGINE_FUNCTION_API,JE_ENGINE_FUNCTION_CALL,FpsCounter)
	}
}

//! DeltaTime macro for use in engine
//! for example 12 * JEDT + 3
#define JEDT (je::core::GetFpsCounter()->GetDT())

//! f64 DeltaTime macro for use in engine
#define JEDT64 (f64)JEDT

//! f32 DeltaTime macro for use in engine
#define JEDT32 (f32)JEDT

#endif
